package com.yuanheng100.ems4j.service;

import com.yuanheng100.ems4j.api.IRoleService;
import com.yuanheng100.ems4j.mapper.Ems4jRoleMapper;
import com.yuanheng100.ems4j.model.Ems4jRole;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by jlqian on 2017/1/11.
 */
public class RoleServiceImpl implements IRoleService
{
    private static Logger logger = Logger.getLogger(RoleServiceImpl.class);

    @Autowired
    private Ems4jRoleMapper ems4jRoleMapper;

    @Override
    public int addRole(Ems4jRole role)
    {
        return ems4jRoleMapper.insert(role);
    }

    @Override
    public boolean updateRole(Ems4jRole role)
    {
        return ems4jRoleMapper.updateByPrimaryKey(role) == 1;
    }

    @Override
    public int addRoleToEmployee(int roleid, int userid)
    {
        return ems4jRoleMapper.addRoleToEmployee(roleid, userid);
    }

    @Override
    public int removeRoleFromEmployee(int roleid, int userid)
    {
        return ems4jRoleMapper.removeRoleFromEmployee(roleid, userid);
    }

    @Override
    public List<Ems4jRole> getRoleList(int appId)
    {
        return ems4jRoleMapper.selectRoleListByAppId();
    }
}
